import {useRoutes,Navigate} from 'react-router-dom'
import {Suspense} from 'react'
import {useSelector,useDispatch} from 'react-redux'
import {getAuthMenuAsync} from './store/modules/menuReducer'

export default ()=>{
    const state=useSelector(state=>{
        return state
    })
    const dispatch=useDispatch()
    const token=state.adminModule.token
    if(token){
      dispatch(getAuthMenuAsync)
    }
    return (<Suspense>
        {useRoutes(state.menuModule.routes)}
    </Suspense>)
}